﻿using AmuTools;
using app.Api;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace app.Models
{
    [Model(TableName = "t_step_data", PrimaryKey = "id", IdentityInsert = true)]
    public class StepData
    {
        [Field(Description = "唯一标识符")]
        public int id { get; set; }


        [Field(Description = "步骤ID")]
        public int step_id { get; set; }


        [Field(Description = "对接ID")]
        public int abutment_id { get; set; }


        [Field(Description = "服务方备注")]
        public string service_remark { get; set; }


        [Field(Description = "逗号分隔的服务方上传附件ID数组")]
        public string service_appendix_ids { get; set; }


        [Field(Storageable = false, Description = "服务方上传附件数组")]
        public List<UploadedFile> service_appendix
        {
            get
            {
                if (service_appendix_ids == "") return new List<UploadedFile>();
                else
                {
                    string condition = string.Format("{0} in ({1})", G.DB.GetPrimaryKey<UploadedFile>(), service_appendix_ids);
                    return G.DB.Get<UploadedFile>(condition).GetFirstTableList<UploadedFile>();
                }
            }
        }


        [Field(Description = "需求方备注")]
        public string demand_remark { get; set; }


        [Field(Description = "逗号分隔的需求方上传附件ID数组")]
        public string demand_appendix_ids { get; set; }


        [Field(Storageable = false, Description = "需求方上传附件数组")]
        public List<UploadedFile> demand_appendix
        {
            get
            {
                if (demand_appendix_ids == "") return new List<UploadedFile>();
                else
                {
                    string condition = string.Format("{0} in ({1})", G.DB.GetPrimaryKey<UploadedFile>(), demand_appendix_ids);
                    return G.DB.Get<UploadedFile>(condition).GetFirstTableList<UploadedFile>();
                }
            }
        }

    }
}